//
//  HJHHomeViewController.swift
//  WeiBoPro
//
//  Created by nadyboy on 2018/4/26.
//  Copyright © 2018年 hjh. All rights reserved.
//

import UIKit
private let cellID = "cellID"

class HJHHomeViewController: HJHBaseViewController{
   //数据源
    var dataSourceList = [String]()
    lazy var statusViewModel = HJHWBStatusViewModel()
    
    override func loadData() {
        print("加载数据--------\(HJHHttpManager.shareInstance)")
     statusViewModel.loadWBStatusData { (isSuceess) in
        if isSuceess == true
        {
            if self.isPull == true
            {
            }else
            {
            }
        }
            self.talebview?.reloadData()
            self.refresh?.endRefreshing()
            //恢复
            self.isPull = false
            }
        }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUI()
    }
}

//设置tableview的数据源和代理方法
extension HJHHomeViewController
{
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return self.statusViewModel.wbStatusArr.count
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .value1, reuseIdentifier: cellID)
         let model = statusViewModel.wbStatusArr[indexPath.row]
        cell.textLabel?.text = model.text
        print("\(model.description )")
        return cell
    }
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.navigationController?.pushViewController(HJHHomeDetailViewController(), animated: true)
    }
}
//设置界面UI
extension HJHHomeViewController
{
    func setUI() {
        let rightBarItem = UIBarButtonItem(title: "扫描", style: .plain, target: self, action: #selector(oo))
        self.navigationItem.rightBarButtonItem = rightBarItem
        talebview?.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
    }
    
    @objc func oo() {
        
    }
}
